home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
310_02
/
ytab.c
< prev
next >
Wrap
Text File
|
1990-04-18
|
22KB
|
740 lines
# define LITNUM 257
# define LITFNUM 258
# define LITCHAR 259
# define LITSTR 260
# define LITSYM 261
# define CLASS 262
# define ASSIGN 263
# define BINARY 264
# define PRIMITIVE 265
# define NAMEDPRIM 266
# define PSEUDO 267
# define UPPERCASEVAR 268
# define LOWERCASEVAR 269
# define COLONVAR 270
# define KEYWORD 271
# define LP 272
# define RP 273
# define LB 274
# define RB 275
# define PERIOD 276
# define BAR 277
# define MBAR 278
# define SEMI 279
# define UPARROW 280
# define PS 281
# define MINUS 282
# define PE 283
# line 26 "parser.y"
# include "env.h"
# include "drive.h"
# include "parser.h"
# line 31 "parser.y"
typedef union {
struct litlist *a;
struct blockstruct *b;
char *c;
struct exprstruct *e;
int i;
struct keylist *k;
struct classstruct *l;
struct methodstruct *m;
struct objstruct *o;
enum pseuvars p;
struct primlist *r;
struct statestruct *s;
struct litstruct *t;
struct primstruct *u
} YYSTYPE;
# line 49 "parser.y"
extern struct blockstruct *mkblock();
extern struct classstruct *mkclass();
extern struct varstruct *mkvar(), *addvlist(), *invlist();
extern struct methodstruct *mkmethod();
extern struct exprstruct *mkexpr(), *mkkey();
extern struct keylist *mkklist();
extern struct statestruct *mkstate();
extern struct objstruct *mkobj();
extern struct primstruct *mkprim();
extern struct primlist *addprim();
extern struct litstruct *mklit();
extern struct litlist *addlit();
extern char *bincat();
struct varstruct *instvars;
struct varstruct *contextvars;
int bytetop = 0;
uchar bytearray[1000];
YYSTYPE e;
int errorcount = 0;
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
extern short yyerrflag;
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 150
#endif
YYSTYPE yylval, yyval;
# define YYERRCODE 256
# line 350 "parser.y"
# include <stdio.h>
char *filename;
FILE *fp;
FILE *ofd;
# include "lexyy.c"
main(argc, argv)
int argc;
char **argv;
{
if (argc != 2) quiter("parser: wrong number of arguments");
filename = argv[1];
fp = fopen(filename, "r");
if (fp == NULL) {
yerr("cannot open input file %s", filename);
quiter("parser quits");
}
ofd = stdout;
return(yyparse());
}
quiter(s) char *s; {fprintf(stderr,"%s\n", s); exit(1);}
yywarn(s, v) char *s, *v; {
fprintf(stderr, "%s: line %d: Warning ", filename, linenum);
fprintf(stderr, s, v);
fprintf(stderr,"\n");
}
yyerror(s) char *s; {yerr(s, "");}
yerr(s, v)
char *s, *v;
{
fprintf(stderr, "%s: line %d: ", filename, linenum);
fprintf(stderr, s, v);
fprintf(stderr,"\n");
if (errorcount++ > 10) quiter("too many errors, goodby");
}
expect(str) char *str;
{ char buffer[100];
sprintf(buffer,"Expected %%s found %s", yytext);
yerr(buffer, str);
}
int yywrap() { return(1);}
char *alloc(size) int size; /* allocate a block of storage */
{ char *p, *malloc();
p = malloc( (unsigned) size);
if (p == (char *) 0) yyerror("out of free space");
return(p);
}
char *bincat(s1, s2)
char *s1, *s2;
{ char *p;
p = alloc(strlen(s1) + strlen(s2) + 1);
strcpy(p, s1);
strcat(p, s2);
return(p);
}
short yyexca[] ={
-1, 1,
0, -1,
-2, 0,
};
# define YYNPROD 120
# define YYLAST 370
short yyact[]={
82, 80, 76, 77, 78, 129, 93, 25, 160, 155,
145, 126, 125, 128, 127, 133, 159, 144, 158, 36,
26, 90, 37, 28, 132, 134, 29, 82, 80, 76,
77, 78, 129, 152, 25, 150, 157, 109, 126, 125,
128, 127, 133, 122, 121, 116, 34, 26, 40, 107,
28, 132, 134, 29, 82, 80, 76, 77, 78, 15,
43, 48, 71, 72, 65, 14, 118, 32, 33, 67,
108, 73, 109, 42, 47, 99, 10, 35, 79, 81,
151, 82, 80, 76, 77, 78, 15, 100, 85, 71,
72, 65, 14, 118, 9, 92, 67, 6, 73, 111,
110, 147, 103, 5, 140, 79, 81, 136, 82, 80,
76, 77, 78, 15, 102, 13, 71, 72, 65, 14,
54, 15, 24, 67, 69, 73, 62, 14, 104, 17,
131, 142, 79, 81, 82, 80, 76, 77, 78, 15,
60, 53, 71, 72, 65, 14, 54, 45, 58, 67,
51, 73, 2, 146, 7, 70, 84, 52, 79, 81,
82, 80, 76, 77, 78, 15, 89, 49, 71, 72,
65, 14, 54, 94, 46, 67, 30, 73, 82, 80,
76, 77, 78, 15, 79, 81, 71, 72, 65, 14,
118, 22, 25, 67, 91, 73, 63, 4, 8, 25,
34, 12, 79, 81, 21, 26, 23, 25, 28, 101,
27, 29, 26, 85, 96, 28, 34, 27, 29, 95,
26, 32, 33, 28, 31, 27, 29, 124, 20, 88,
1, 137, 135, 97, 115, 41, 117, 32, 33, 120,
113, 114, 66, 39, 153, 119, 149, 141, 123, 64,
143, 139, 138, 50, 16, 3, 11, 20, 19, 44,
75, 105, 137, 83, 106, 148, 38, 61, 59, 57,
55, 87, 56, 18, 124, 74, 86, 68, 0, 98,
0, 154, 0, 0, 156, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 130, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 130 };
short yypact[]={
-159,-159,-1000,-180,-141,-1000,-1000,-1000, -65,-1000,
-1000,-210,-193,-1000,-1000,-1000,-256,-1000,-210,-223,
-196,-1000,-1000,-196, -72,-1000,-1000,-1000,-1000,-1000,
-1000,-195,-1000,-1000,-1000,-1000,-1000, -65,-123,-181,
-196,-1000,-1000,-1000,-1000,-1000, -40,-1000,-1000,-1000,
-255,-1000, -97,-1000,-168,-273,-1000,-1000, -57, -57,
-194,-182,-1000,-1000,-1000,-1000,-1000, -97,-1000,-1000,
-1000,-155,-1000,-221,-1000,-1000,-1000,-1000,-1000,-202,
-1000,-158,-1000, -56,-1000,-1000,-1000,-1000,-1000,-1000,
-123,-1000, -97,-1000,-226, -79, -79,-226, -79,-1000,
-1000,-229,-230,-1000,-176,-149,-260,-1000,-1000,-156,
-1000,-1000,-1000,-1000,-1000,-1000, -79,-194,-1000, -72,
-194,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
-1000,-1000,-237,-1000,-158,-203,-1000,-1000,-242,-149,
-1000,-267, -97,-1000,-1000,-1000,-239,-1000, -72,-257,
-1000,-1000,-1000,-1000,-268,-1000,-1000,-1000,-1000,-1000,
-1000 };
short yypgo[]={
0, 114, 277, 196, 219, 122, 275, 273, 272, 270,
148, 140, 269, 268, 267, 266, 264, 263, 261, 260,
258, 173, 256, 255, 129, 254, 126, 128, 253, 150,
141, 252, 251, 104, 250, 249, 124, 248, 242, 230,
152, 198, 197, 176, 224, 174, 166, 235, 156, 155,
153, 130 };
short yyr1[]={
0, 39, 39, 40, 41, 41, 23, 42, 42, 22,
22, 22, 3, 3, 43, 43, 45, 45, 45, 25,
25, 24, 7, 7, 7, 7, 20, 20, 47, 47,
15, 15, 44, 44, 44, 17, 17, 48, 28, 28,
46, 46, 29, 29, 30, 30, 9, 9, 12, 12,
13, 13, 14, 14, 8, 8, 21, 21, 10, 10,
4, 4, 5, 5, 5, 5, 5, 11, 11, 26,
26, 26, 26, 26, 26, 26, 38, 38, 27, 27,
2, 18, 18, 16, 16, 31, 31, 33, 33, 34,
34, 32, 32, 35, 35, 49, 36, 36, 36, 36,
36, 36, 6, 6, 19, 19, 37, 37, 37, 37,
37, 37, 37, 37, 51, 51, 1, 1, 50, 50 };
short yyr2[]={
0, 1, 2, 4, 1, 1, 3, 1, 1, 1,
2, 1, 1, 1, 0, 3, 1, 2, 1, 1,
3, 4, 1, 2, 1, 1, 2, 3, 1, 1,
0, 3, 1, 1, 1, 1, 2, 1, 1, 3,
0, 1, 2, 1, 3, 1, 1, 1, 1, 2,
1, 3, 2, 2, 1, 2, 2, 3, 1, 3,
1, 2, 1, 1, 1, 1, 1, 1, 2, 1,
1, 1, 1, 1, 3, 1, 4, 3, 0, 2,
4, 0, 2, 1, 2, 2, 1, 2, 1, 0,
1, 2, 3, 1, 3, 2, 1, 1, 1, 1,
1, 4, 1, 2, 1, 2, 1, 1, 1, 1,
1, 1, 1, 3, 2, 1, 0, 2, 1, 2 };
short yychk[]={
-1000, -39, -40, -23, -42, 262, 256, -40, -41, 274,
256, -22, -3, 256, 268, 262, -25, -24, -7, -20,
-4, 269, 256, 271, -5, 264, 277, 282, 280, 283,
-43, -44, 277, 278, 256, 270, 275, 278, -15, -44,
271, -47, 269, 256, -47, -5, -45, 269, 256, -24,
-28, -29, 280, -30, 269, -9, -8, -12, -10, -13,